# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


class LogincsdnPipeline(object):
	def process_item(self, item, spider):
		if(item['coursenum'] == ''):
			resultItem = '{"课程名": '+item['title']+', "学员人数": '+item['num']+', "课程定价": '+item['money']+', "课时数": '+item['pinfo']+'}\n'
		else:
			resultItem = '{"课程名": '+item['title']+', "包含课程": '+item['coursenum']+', "课程定价": '+item['money']+', "课时数": '+item['pinfo']+'}\n'
		
		with open('course/course.txt', 'a') as f:
			print('正在写入：'+resultItem)
			if (f.write(resultItem)):
				print('写入成功')
		return item
